package com.cltech.frame.result;

/**
 * Created by Administrator on 2018/8/18.
 */

import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;

import java.io.Serializable;
@JsonInclude(JsonInclude.Include.NON_NULL)
@Data
public class ResponseBean<T> implements Serializable {
    private Integer status = 200;
    private String msg;
    private T data;
    private Boolean isSuccess;

    public static <T> ResponseBean<T> success(String msg, T data) {
        return new ResponseBean<>(200, true, msg, data);
    }
    public static <T> ResponseBean<T> success(String msg) {
        return new ResponseBean<>(200, true, msg, null);
    }
    public static <T> ResponseBean<T> success(T data) {
        return new ResponseBean<>(200, true, "操作成功", data);
    }
    public static <T> ResponseBean<T> fail(String msg) {
        return new ResponseBean<>(200, false, msg, null);
    }
    public static <T> ResponseBean<T> error(Integer status,String msg) {
        return new ResponseBean<>(status, false, msg, null);
    }
    public ResponseBean(Integer status, Boolean isSuccess, String msg, T data) {
        this.status = status;
        this.isSuccess = isSuccess;
        this.msg = msg;
        this.data = data;
    }

    public ResponseBean(Integer status, String msg) {
        this.status = status;
        this.msg = msg;
    }
}

